<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>成员管理</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">

</head>
<body>
<%@include file="../include/header.jsp" %>

<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <div class="section-main">
            <form class="layui-form"
                    <c:if test="${empty myGroup.id}">
                        action="${ctx}/sign/member/list.do?projectId=${signProject.id}"
                    </c:if>
                    <c:if test="${empty myGroup.id}">
                        action="${ctx}/sign/member/list.do?projectId=${signProject.id}&newGroupId=${myGroup.id}"
                    </c:if>
                  id="myForm" method="post">
                <input type="hidden" name="pageNo" id="pageNo"/>
                <div class="f-search-bar">
                    <div class="search-container">
                        <ul class="search-form-content">
                            <li class="form-item-inline"><label class="search-form-lable">成员名</label>
                                <div class="layui-input-inline">
                                    <input type="text" name="memberName" autocomplete="off" class="layui-input"
                                           value="${groupMember.memberName}"
                                           placeholder="请输入查询成员名"
                                    >
                                </div>
                            </li>
                            <c:if test="${empty myGroup.id}">
                                <li class="form-item-inline"><label class="search-form-lable">所属队伍</label>
                                    <div class="layui-input-inline">
                                        <select name="groupId">
                                            <option value="">全部</option>
                                            <c:forEach var="group" items="${signGroupList}">
                                                <option value="${group.id}" ${groupMember.groupId == group.id ? 'selected="selected"' : ""}>${group.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </li>
                            </c:if>
                            <li class="form-item-inline">
                                <div class="sub-btns">
                                    <a class="layui-btn layui-btn-danger"
                                       href="javascript:submitFunction('#myForm')">查询</a>
                                    <a class="layui-btn layui-btn-normal"
                                       href="javascript:resetFunction('#myForm')">重置</a>
                                </div>
                            </li>
                        </ul>
                        <ul class="search-form-content">
                            <li class="form-item"><label class="search-form-lable">申请时间</label>
                                <div class="check-btn-inner" id="timeType">
                                    <a id="all" href="javascript:void(0);"
                                       onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                    <a href="javascript:void(0);"
                                       onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                    <input type="hidden" name="timeType" value="${input.timeType}"/>
                                </div>
                                <div class="layui-inline">
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createStart"
                                               value="${input.createStart}" placeholder="开始日">
                                    </div>
                                    -
                                    <div class="layui-input-inline">
                                        <input class="layui-input" type="text" name="createEnd"
                                               value="${input.createEnd}" placeholder="截止日">
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
            </form>

            <div class="my-act-list-content">
                <div class="cl">
                    <table class="layui-table">
                        <colgroup>
                            <col width="75px">
                            <col>
                            <col>
                            <col>
                            <col width="130px">
                            <col>
                            <col width="150px">
                            <%--<col>--%>
                            <col>
                        </colgroup>
                        <thead>
                        <tr>
                            <th>序号</th>
                            <th>成员名</th>
                            <th>公司</th>
                            <th>职务</th>
                            <th>联系电话</th>
                            <th>所属队伍</th>
                            <th>申请时间</th>
                            <%--<th>审核状态</th>--%>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <c:if test="${page.totalCount == 0}">
                            <tr>
                                <td colspan="8" align="center">还没有数据</td>
                            </tr>
                        </c:if>
                        <c:forEach var="apply" items="${list}" varStatus="st">
                            <tr>
                                <td>${page.limit * (page.page-1) + st.count}</td>
                                <td class="table-member"
                                    onclick="openDialogShow('成员名片','${ctx}/system/member/memberView.do?id=${apply.memberId}','400px','470px')">
                                    <div class="member-cell">
                                        <div class="member-logo common-img">
                                            <img src="<c:if test="${ apply.memberLogo!= null}">${apply.memberLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt=""
                                                 onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                        </div>
                                        <div class="member-name ellipsis-1"><a class="blue" title="${apply.memberName}"
                                                                               href="javascript:void(0);">${apply.memberName}</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <div class="ellipsis-1" title="${apply.memberCompany}">${apply.memberCompany}</div>
                                </td>
                                <td>
                                        ${apply.memberJobTitle}
                                </td>
                                <td>
                                        ${apply.memberMobile}
                                </td>
                                <td>
                                        ${apply.groupName}

                                </td>
                                <td>
                                    <fmt:formatDate value="${apply.createDate}" pattern="yyyy-MM-dd HH:mm"/>

                                </td>
                                    <%--<td>
                                        <c:if test="${apply.status == 0}">
                                            待审核
                                        </c:if>
                                        <c:if test="${apply.status == 1}">
                                            审核通过
                                        </c:if>
                                        <c:if test="${apply.status == 2}">
                                            审核拒绝
                                        </c:if>
                                    </td>--%>
                                <td class="tb-opts">
                                    <div class="comm-opts">
                                        <c:if test="${not empty myGroup.id}">
                                            <a href="javascript:cancelJoinGroup('${apply.id}')" target="_self">
                                                移除成员
                                            </a>
                                        </c:if>

                                        <a href="javascript:txz.deleteObject('确定删除成员？', '${ctx}/sign/member/delete.do?id=${apply.id}')" target="_self">
                                            删除成员
                                        </a>
                                        <c:if test="${apply.status == 1}">
                                            <a href="javascript:openDialog('分配队伍','${ctx}/sign/member/distribute.do?id=${apply.id}','400px','300px')"
                                               target="_self">
                                                分配队伍
                                            </a>
                                        </c:if>
                                    </div>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="page-content">
                <c:if test="${page.totalCount > 0}">
                    <div class="l page-totalcount"><span class="f14 red">共<b
                            id="totalCount">${page.totalCount}</b>条记录</span></div>
                </c:if>
                <div id="page_content" class="page-container"></div>
            </div>
            <%--</div>--%>
            <%--</div>--%>
        </div>
        <%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>

<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            var start = {
                elem: 'input[name=createStart]'
            };

            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        })
    });


    function checkApply(id, status) {
        var info;
        if (status == 1) {
            info = "确定要通过吗?";
        }
        else if (status == 2) {
            info = "确定要拒绝吗?"
        }
        layer.confirm(info, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            $.post("${ctx}/sign/member/check.do", {id: id, status: status}, function (data) {
                if (data.success == true) {
                    util.layerAlertSuccess("审核成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerMsgError("审核失败")
                }
            });
        });
    }
    ;

    function checkGrade(id, status) {
        var info;
        if (status == 1) {
            info = "确定成绩有效?";
        }
        else if (status == 0) {
            info = "确定成绩无效?"
        }
        layer.confirm(info, {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            $.post("${ctx}/sign/member/checkGrade.do", {id: id, status: status}, function (data) {
                if (data.success == true) {
                    util.layerMsgSuccess("审核成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerMsgError("审核失败")
                }
            });
        });
    }

    function cancelJoinGroup(applyId) {
        layer.confirm('确定移除成员？', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            $.post("${ctx}/sign/group/cancelJoinGroup.do", {
                applyId: applyId
            }, function (data) {
                if (data.success == true) {
                    util.layerMsgSuccess("移除成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerMsgError("移除失败")
                }
            });
        });
    }
    ;

    function openDialog(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }
</script>
<script type="text/javascript">
    <c:if test="${not empty myGroup.id}">
    txz.initHeader({
        nav: [{
            name: '打卡项目管理',
            href: '${ctx}/sign/project/list.do'
        }, {
            name: '${signProject.title}',
            href: '${ctx}/sign/project/list.do'
        }, {
            name: '${myGroup.name}'
        }, {
            name: '成员管理',
            curr: true
        }],
        btns: [{
            name: '返回',
            icon: 'back',
            href: '${ctx}/sign/group/list.do?projectId=${signProject.id}&newGroupId=${myGroup.id}'
        }]
    });
    </c:if>
    <c:if test="${empty myGroup.id}">
    txz.initHeader({
        nav: [{
            name: '打卡项目管理',
            href: '${ctx}/sign/project/list.do'
        }, {
            name: '${signProject.title}',
            href: '${ctx}/sign/project/list.do'
        }, {
            name: '成员管理',
            curr: true
        }],
        btns: [{
            name: '返回',
            icon: 'back',
            href: '${ctx}/sign/project/list.do'
        }]
    });
    </c:if>
</script>
</body>
</html>
